<template>
  <el-form :model="fromData" label-width="100px" :show-message="false" :rules="fromDataRules" ref="fromData">
    <el-form-item label="工单编号:">
      <span>{{fromData.code}}</span>
    </el-form-item>
    <el-form-item label="工单金额:">
      <span>￥{{fromData.amount}}</span>
    </el-form-item>
    <el-form-item label="申请备注:" prop="remark">
      <el-input type="textarea" v-model="fromData.remark" clearable show-word-limit :autosize="{ minRows: 4, maxRows: 6 }" placeholder="备注"></el-input>
    </el-form-item>
    <el-row>
      <el-col :span="24" align="center">
        <el-button type="primary" @click="onSubmit">确认</el-button>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
  import { refundProcess } from "@/api/after-sale/workOrderManage/orderManage";
  export default {
    name: 'DialogDataForm',
    props: {
      value: {
        type: Object,
        default: () => ({})
      },
      type: {
        type: String,
        default: () => ('')
      }
    },
    data() {
      return {
        fromData: {
          code: '',
          amount: null,
          remark: '',
          status: 0,
        },
        fromDataRules: {
          remark: [{required: true, trigger: 'blur'}],
        }
      }
    },
    created() {
      const {code, amount, id} = this.value;
      this.fromData.code = code;
      this.fromData.amount = amount;
      this.fromData.billId = id;
    },
    methods: {
      onSubmit() {
        this.$refs.fromData.validate(valid => {
          if (valid) {
              refundProcess().then(res=> {
                if (res.success) {
                  this.$message.success('操作成功');
                  this.$emit('close', true)
                } else {
                  this.$message.error(res.message)
                }
              })
          } else {
            return false
          }
        })
      },
    },
  }
</script>
<style lang="scss" scoped>
</style>

